FROM vulhub/ubuntu:12.04

RUN sed -i 's|http://archive.ubuntu.com/ubuntu/|http://old-releases.ubuntu.com/ubuntu/|g' /etc/apt/sources.list && \
    sed -i 's|http://security.ubuntu.com/ubuntu/|http://old-releases.ubuntu.com/ubuntu/|g' /etc/apt/sources.list


RUN apt-get update -o Acquire::Check-Valid-Until=false && \
    apt-get upgrade -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 libtinfo5 && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*
    
    
COPY packages /packages

RUN dpkg -i /packages/*

COPY vulnerable /usr/lib/cgi-bin/
COPY index.html /var/www

RUN chown www-data:www-data /var/www/index.html

RUN cd /etc/apache2/mods-enabled && \ 
    ln -s ../mods-available/cgi.load

EXPOSE 80

COPY main.sh /

ENTRYPOINT ["/main.sh"]
CMD ["default"]
